package com.laolang.shop.modules.product.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.laolang.shop.modules.product.entity.ProductAttr;
import com.laolang.shop.modules.product.mapper.ProductAttrMapper;
import com.laolang.shop.modules.product.pojo.attr.admin.vo.ProductAttrPageVo;
import com.laolang.shop.modules.product.service.ProductAttrService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;

/**
 * @author khlbat
 * @version 1.0
 * @date 2020/11/4 18:52
 */
@AllArgsConstructor
@Service
public class ProductAttrServiceImpl extends ServiceImpl<ProductAttrMapper, ProductAttr> implements ProductAttrService {

    private final ProductAttrMapper productAttrMapper;

    @Override
    public boolean save(ProductAttr entity) {
        entity.setVersion(1);
        entity.setCreateTime(LocalDateTime.now());
        return false;
    }

    @Override
    public PageInfo<ProductAttrPageVo> page(Integer page, Integer size, Long cateId) {
        PageHelper.startPage(page, size);
        return new PageInfo<>(productAttrMapper.page(cateId));
    }
}
